
from generate_panel_image import PanelImage
from custom_logger import PrefixDateLogger
from email_send import  SendEmail
from generate_mail_table import CpaData
import time  # 导入time模块，用于添加延迟
# -------------------------- 配置参数（必须修改）--------------------------

# ------------------------------------------------------------------------
logger = PrefixDateLogger("send_data_email")
# 执行脚本
if __name__ == "__main__":
    # 创建连接实例
    panel_image = PanelImage()
    email=SendEmail()
    cpa = CpaData()
    compare_data=cpa.get_compare_data()
    image_path = panel_image.general_image("adfz9wv",
                                           "f79426e",
                                           None,
                                           2000)
    logger.info(f"image_path:{image_path}")
    if image_path:
        # 邮件正文（支持HTML）
        body = f"""
        <p>下面表格是最近7天新旧统计方案对比：</p>
        <img src="cid:graph1" style="max-width:600px;"><br>
        <p>附件为仪表盘截图，可查看详细数据趋势：</p>
        <p><a href="http://47.245.149.255:3000/public-dashboards/fd6c81699536423092be41d0693b0f0a">点击跳转至Grafana在线查看</a></p>
        """
        title="最近7天活跃新旧统计方案对比"
        email.send_email_with_screenshot(title,body,image_path)